<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of comment
 *
 * @author dmitryy
 */
class Controller_Comment extends Controller_Action {
    function index() 
    {
        $this->registry->get('view')->show('showallcomments');
    }
    
    function add()
    {
        $this->registry->get('view')->show('addcomment');
    }
    
    function check()
    {
        $content = new Models_Comment();
        $validate = $content->validate($_POST);
        $this->registry->get('view')->set('firstname',$_POST['0']);
        $this->registry->get('view')->set('surename',$_POST['1']);
        $this->registry->get('view')->set('title',$_POST['2']);
        $this->registry->get('view')->set('body',$_POST['3']);
        $this->registry->get('view')->set('post',$_POST['4']);
        if($validate)
        {
            $this->registry->get('view')->set('validate',$validate);
            $this->registry->get('view')->show('addcomment');
        } else {
            $this->registry->get('view')->show('addedcomment');
        }
    }

    function show($id)
    {
        if($id == 'all')
        {
            $this->registry->get('view')->show('showallcomments');
        } else {
            $this->registry->get('view')->set('id',$id);
            $this->registry->get('view')->show('showcomment');
        }
    }
}